package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.Comment;
import cn.wolfcode.trip.base.service.ICommentService;
import cn.wolfcode.trip.base.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/comments")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    /**
     * 保存攻略评论的点评数据
     * @param comment
     * @return
     */
    @PostMapping
    public JsonResult save(Comment comment) {
        JsonResult result = new JsonResult();
        try {
            commentService.saveOrUpdate(comment);
        } catch (Exception e) {
            e.printStackTrace();
            result.mark(e.getMessage());
        }
        return result;
    }
    @GetMapping("{strategyCommentId}")
    public Integer queryCountByStrategyCommentId(@PathVariable Long strategyCommentId) {

        return commentService.queryCountByStrategyCommentId(strategyCommentId);
    }


}
